package com.hbnu.tagyalu;

import java.io.IOException;
import java.io.PipedInputStream;

public class Receive implements Runnable{
    private PipedInputStream pipedInputStream;

    public Receive() {
        this.pipedInputStream=new PipedInputStream();
    }

    public PipedInputStream getPipedInputStream() {
        return pipedInputStream;
    }

    @Override
    public void run() {
        try {
            byte[] bytes=new byte[1024];
            int len=0;
            int temp;
            while ((temp=pipedInputStream.read())!=-1){
                bytes[len++]=(byte) temp;
            }
        }catch (IOException e){
            e.printStackTrace();
        }
        finally {
            try {
                if (pipedInputStream!=null){
                    pipedInputStream.close();
                }
            }
            catch (IOException e){
                e.printStackTrace();
            }
        }
    }
}
